import React from 'react';
import {HeaderButtons, Item} from 'react-navigation-header-buttons';
import {connect} from 'react-redux';
import {IState} from '@/common/type';
interface Iprops {
  onSubmit: () => void;
  isEdit: Boolean;
}
class HeaderRightBtn extends React.Component<Iprops> {
  render(): React.ReactNode {
    const {onSubmit, isEdit} = this.props;
    console.log(isEdit, '-----------HeaderRightBtn');
    return (
      <HeaderButtons>
        <Item title={isEdit ? '完成' : '编辑'} onPress={onSubmit} />
      </HeaderButtons>
    );
  }
}

export default connect((state: IState) => ({
  isEdit: state.counter.isEdit,
}))(HeaderRightBtn);
